﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class LineTechnologyProcessRouteConfig : POBaseConfig<LineTechnologyProcessRoutePO>
    {
        public override void InitializeData(EntityTypeBuilder<LineTechnologyProcessRoutePO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<LineTechnologyProcessRoutePO> builder, ref int index)
        {
            builder.HasComment("工艺工序路径配置表");
            builder.Property(entity => entity.LineCode).ConfigColumn("LINE_CODE", "产线编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TechnologyProcessCode).ConfigColumn("TECHNOLOGY_PROCESS_CODE", "工艺工序编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.StationCode).ConfigColumn("STATION_CODE", "站台编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.MesOperationCode).ConfigColumn("MES_OPERATION_CODE", "MES工序编码", 50).HasColumnOrder(index++);
            builder.Property(entity => entity.MesEquipmentCode).ConfigColumn("MES_EQUIPMENT_CODE", "MES设备编码", 50).HasColumnOrder(index++);
            builder.Property(entity => entity.MesResourceCode).ConfigColumn("MES_RESOURCE_CODE", "MES资源编码", 50).HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<LineTechnologyProcessRoutePO> builder)
        {
            builder.HasIndex(entity => new { entity.TechnologyProcessCode, entity.LineCode, entity.WarehouseCode }).HasDatabaseName($"UN_{TableName}_1").IsUnique();
        }
    }
}
